﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Lucene.Net.Search;
using Lucene.Net.QueryParsers;
using Lucene.Net.Documents;
using Lucene.Net.Analysis;
using Lucene.Net.Index;
using Lucene.Net.Store;
using Lucene.Net.Analysis.Standard;
using htmlParser = Winista.Text.HtmlParser;
using Winista.Text.HtmlParser.Visitors;
using Winista.Text.HtmlParser.Util;
using Winista.Text.HtmlParser.Filters;
using Winista.Text.HtmlParser.Tags;
using Winista.Text.HtmlParser;
using Winista.Text.HtmlParser.Lex;
using System.Text.RegularExpressions;
using System.Text;
using System.Linq;
using OgilvyOne.UKNOW.Entity;
using System.Configuration;
using OgilvyOne.UKNow.BLL;
using OgilvyOne.UKNow.Model;
using ECCIT;

public partial class cn_search : System.Web.UI.Page
{
    public string searchKey;
    public string searchCount = "0";
    public string searchResult;
    public string keywords = "";
    public string imgEventsResult;
    public string imgWarmUpResult;
    public string videoSeaResult;
    public string type;
    public int currPageIndex;

    public string wordCount = "0";
    public string picCount = "0";
    public string videoCount = "0";

    private const int IMAGE_PAGESIZE = 25;//分页图片每页显示个数
    private const int WORDS_PAGESIZE = 10;//分页文字每页显示个数
    private const int VIDEO_PAGESIZE = 10;//分页视频每页显示个数
    private const string CURRINDEX = "currIndex"; //当前页号参数名
    private const string KEYWORDS = "keywords"; //关键字参数名

    private PagingList PagingCollection(IList<MediaFileModel> list, int pageSize, int currentPageIndex)
    {
        int totalRecordCount = list.Count;
        int iPageSize = pageSize;
        int iCurrentPageIndex = currentPageIndex;

        if (iPageSize == 0) return null;
        if (list.Count == 0) return null;

        PagingList pagingList = new PagingList(new List<MediaFileModel>(), 0);
        pagingList.Capacity = totalRecordCount;

        int iStartRecordIndex = iPageSize * iCurrentPageIndex;
        int iEndRecordIndex = iPageSize * (iCurrentPageIndex + 1);
        if (iEndRecordIndex > totalRecordCount) iEndRecordIndex = totalRecordCount;

        for (int i = iStartRecordIndex; i < iEndRecordIndex; ++i)
            pagingList.List.Add(list[i]);

        return pagingList;

    }

    private PagingList GetImgValue(string keyword, int currIndex, int pageSize)
    {
        WarmupBLL wb = new WarmupBLL(2052);
        EventsBLL ebll = new EventsBLL(2052);
        // List<MediaFileModel> lmm = wb.returnSource(keyword, 2052);
        //
        List<MediaFileModel> lmm = wb.returnSource(keyword, 2052);
        //List<MediaFileModel> lmm1 = wb.returnSource(keyword, 2052, 2, currIndex, imgSize);
        //mm.AddRange(lmm1);

        // 根据mediaType把图片数据过滤出来
        var filteredList = from lm in lmm
                           where lm.MediType != 1
                           select lm;

        // 把合并后的图片集合进行分页
        int totalCount = filteredList.Count<MediaFileModel>();
        int pageCount = totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize + 1;
        if (currIndex > pageCount - 1)
            currIndex = pageCount - 1;
        if (currIndex < 0)
            currIndex = 0;
        PagingList pagingImages = PagingCollection(filteredList.Cast<MediaFileModel>().ToList<MediaFileModel>(), pageSize, currIndex);
        return pagingImages;
    }
    private PagingList GetVideoValue(string keyword, int currIndex, int pageSize)
    {
        WarmupBLL wb = new WarmupBLL(2052);
        EventsBLL ebll = new EventsBLL(2052);
        // List<MediaFileModel> lmm = wb.returnSource(keyword, 2052);
        //
        List<MediaFileModel> lmm = wb.returnSource(keyword, 2052);
        //List<MediaFileModel> lmm1 = wb.returnSource(keyword, 2052, 2, currIndex, imgSize);
        //mm.AddRange(lmm1);

        // 根据mediaType把视频数据过滤出来
        var filteredList = from lm in lmm
                           where lm.MediType == 1
                           select lm;

        // 把合并后的图片集合进行分页
        int totalCount = filteredList.Count<MediaFileModel>();
        int pageCount = totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize + 1;
        if (currIndex > pageCount - 1)
            currIndex = pageCount - 1;
        if (currIndex < 0)
            currIndex = 0;
        PagingList pagingImages = PagingCollection(filteredList.Cast<MediaFileModel>().ToList<MediaFileModel>(), pageSize, currIndex);
        return pagingImages;

    }


    private string GetEventsImgValue(string keyword, int currIndex, int imgSize)
    {
        WarmupBLL wb = new WarmupBLL(2052);
        EventsBLL ebll = new EventsBLL(2052);
        PagingList pagingImages = GetImgValue(keyword, currIndex, imgSize);
        if (pagingImages != null)
        {
            int total = pagingImages.Capacity;  // wb.returnNum(keyword, 2052, 0);
           
            int pageNum = 0;
            if (total % 25 == 0)
            {
                pageNum = (total / 25);
            }
            else
            {
                pageNum = (total / 25) + 1;
            }
            List<MediaFileModel> lmm = pagingImages.List.Cast<MediaFileModel>().ToList<MediaFileModel>();
            string imgevent = "";
            if (lmm != null)
            {
                if (lmm.Count != 0)
                {
                    imgevent += "<ol class='result'>";
                    foreach (MediaFileModel mfm in lmm)
                    {
                        if (mfm.MediType == 0)
                        {//活动图片
                            EventsModel emodel = ebll.selEvent(Convert.ToInt32(mfm.ID));
                            string content = emodel != null ? emodel.Detail : null;
                            string def = "/cn/images/def_warmup.JPG";
                            string src = "";
                            if (mfm.Path == "" || mfm.Path == null)
                            {
                                src = def;
                            }
                            else
                            {
                                src = "../uploadfiles/image/" + mfm.Path;
                            }
                            imgevent += "<li><a href='events/" + mfm.ID + ".html'><image width='130px' height='130px' onerror='this.src='" + def + "'' src='" + src + "'></a><a href='events/" + mfm.ID + ".html'><span>" + mfm.Name + "</span></a></li>";
                        }
                        else if (mfm.MediType == 2)
                        {//作品图片
                            WarmupModel wmodel = wb.GetWarmupById(Convert.ToInt32(mfm.ID));
                            string content = wmodel.Description;
                            string def = "/cn/images/def_warmup.JPG";
                            string src = "";
                            if (mfm.Path == "")
                            {
                                src = def;
                            }
                            else
                            {
                                src = "../uploadfiles/image/" + mfm.Path;
                            }
                            //<li><img src="images/element_temp_1.jpg" width="130" height="130" alt="" /><span>文字<font color=red>英国</font>文字<font color=red>英国</font>文字</span></li>
                            imgevent += "<li><a href='interactivedetail.aspx?wid=" + mfm.ID + "&&currPageIndex=0&&sortType=null&&sortDirect=null'><img src='" + src + "' width='130' height='130' alt='' /></a><span>" + mfm.Name + "</span></li>";
                        }
                    }
                    imgevent += "</ol>";
                    imgevent += "<div class='resultpage'>";
                    imgevent += "<ol>"; 
                    int indexPage = int.Parse(ViewState[CURRINDEX].ToString().Substring(0, 1));
                    if ((indexPage - 1) < 0)
                    {
                        imgevent += "<li><a href='search.aspx?type=1&currIndex=0&keywords=" + keyword + "'><img src='images/icon_comment_pre.gif' alt='' /></a></li>";
                    }
                    else
                    {
                        imgevent += "<li><a href='search.aspx?type=1&currIndex=" + (indexPage - 1) + "&keywords=" + keyword + "'><img src='images/icon_comment_pre.gif' alt='' /></a></li>";
                    }
                    for (int i = 0; i < pageNum; i++)
                    {
                        imgevent += "<li><a href='search.aspx?type=1&currIndex=" + i + "&keywords=" + keyword + "'>" + (i + 1) + "</a></li>";
                    }
                    if (indexPage == pageNum)
                    {
                        imgevent += "<li><a href='search.aspx?type=1&currIndex=" + pageNum + "&keywords=" + keyword + "'><img src='images/icon_comment_next.gif' alt='' /></a></li>";
                    }
                    else
                    {
                        imgevent += "<li><a href='search.aspx?type=1&currIndex=" + (indexPage + 1) + "&keywords=" + keyword + "'><img src='images/icon_comment_next.gif' alt='' /></a></li>";

                    }
                    imgevent += "</ol>";
                    imgevent += "</div>";
                    return imgevent;
                }
                else
                {
                    return null;
                }
            }
            else
            {
                return null;
            }
        }
        else
        {
            return null;
        }
    }

    //private string GetWarmUpImgValue(string keyword, int currIndex, int imgSize)
    //{
    //    WarmupBLL wb = new WarmupBLL(2052);
    //    EventsBLL ebll = new EventsBLL(2052);
    //    List<MediaFileModel> lmm = wb.returnSource(keyword, 2052, 2, currIndex, imgSize);
    //    string imgwarmupt = "";
    //    if (lmm != null)
    //    {
    //        if (lmm.Count != 0)
    //        {
    //            foreach (MediaFileModel mfm in lmm)
    //            {
    //                WarmupModel wmodel = wb.GetWarmupById(Convert.ToInt32(mfm.ID));
    //                string content = wmodel.Description;
    //                string def = "/cn/images/def_warmup.JPG";
    //                string src = "../uploadfiles/image/" + mfm.Path;
    //                if (mfm.Path != "")
    //                {
    //                    //<li><img src="images/element_temp_1.jpg" width="130" height="130" alt="" /><span>文字<font color=red>英国</font>文字<font color=red>英国</font>文字</span></li>
    //                    imgwarmupt += "<li><a href='interactivedetail.aspx?wid=" + mfm.ID + "&&currPageIndex=0&&sortType=null&&sortDirect=null'><img src='" + src + "' width='130' height='130' alt='' /></a><span>" + mfm.Name + "</span></li>";
    //                }
    //            }
    //            return imgwarmupt;
    //        }
    //        else
    //        {
    //            return null;
    //        }
    //    }
    //    else
    //    {
    //        return null;
    //    }
    //}

    private string GetEventsVideoValue(string keyword, int currIndex, int imgSize)
    {
        WarmupBLL wb = new WarmupBLL(2052);
        EventsBLL ebll = new EventsBLL(2052);
        PagingList pagingValue = GetVideoValue(keyword, currIndex, imgSize);
        if (pagingValue != null)
        {
            int total = pagingValue.Capacity;  // wb.returnNum(keyword, 2052, 0);
            
            int pageNum = 0;
            if (total % 25 == 0)
            {
                pageNum = (total / 25);
            }
            else
            {
                pageNum = (total / 25) + 1;
            }
            List<MediaFileModel> lmm = pagingValue.List.Cast<MediaFileModel>().ToList<MediaFileModel>();
            string videoinfo = "";
            if (lmm.Count != 0)
            {
                videoinfo += "<dl class='video'>";
                foreach (MediaFileModel mfm in lmm)
                {
                    WarmupModel wmodel = wb.GetWarmupById(Convert.ToInt32(mfm.ID));
                    string content = wmodel.Description;
                    string username = wmodel.Author.Name;
                    string def = "/cn/images/def_video.jpg";
                    string src = "";
                    if (mfm.Path == "" || mfm.Path == null)
                    {
                        src = def;
                    }
                    else
                    {
                        src = "../uploadfiles/image/" + mfm.Path;
                    }


                    videoinfo += "<dt><a href='events/" + mfm.ID + ".html'><img src='" + src + "' width='130' height='130' onerro='this.src=\"/cn/images/def_video.jpg\"' alt='' /></a></dt>";
                    videoinfo += "<dd><span><a href='events/" + mfm.ID + ".html'>" + username + "</a></span>" + content + "</dd>";

                }
                videoinfo += "</dl>";
                videoinfo += "<div class='resultpage'>";
                videoinfo += "<ol>";
                int indexPage = int.Parse(ViewState[CURRINDEX].ToString());
                if ((indexPage - 1) < 0)
                {
                    videoinfo += "<li><a href='search.aspx?type=2&currIndex=0&keywords=" + keyword + "'><img src='images/icon_comment_pre.gif' alt='' /></a></li>";
                }
                else
                {
                    videoinfo += "<li><a href='search.aspx?type=2&currIndex=" + (indexPage - 1) + "&keywords=" + keyword + "'><img src='images/icon_comment_pre.gif' alt='' /></a></li>";
                }
                for (int i = 0; i < pageNum; i++)
                {
                    videoinfo += "<li><a href='search.aspx?type=2&currIndex=" + i + "&keywords=" + keyword + "'>" + (i + 1) + "</a></li>";
                }
                if (indexPage == pageNum)
                {
                    videoinfo += "<li><a href='search.aspx?type=2&currIndex=" + (indexPage) + "&keywords=" + keyword + "'><img src='images/icon_comment_next.gif' alt='' /></a></li>";

                }
                else
                {
                    videoinfo += "<li><a href='search.aspx?type=2&currIndex=" + (indexPage + 1) + "&keywords=" + keyword + "'><img src='images/icon_comment_next.gif' alt='' /></a></li>";
                }
                videoinfo += "</ol>";
                videoinfo += "</div>";

                return videoinfo;
            }
            else
            {
                return null;
            }
        }
        else
        {
            return null;
        }

    }

    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {


            if (!String.IsNullOrEmpty(this.Request["value"]))
            {
                ViewState["value"] = this.Request["value"];
                //WarmupBLL wbll1 = new WarmupBLL(2052);
                //MediaNum mn = wbll1.returnMediaNum(this.Request["value"], 2052);
                //ViewState["picNum"] = mn.Imgnum.ToString();
                //ViewState["videoNum"] = mn.Videonum.ToString();
                //ViewState["wordNum"] = searchCount;
            }

            if (!string.IsNullOrEmpty(this.Request.Params["currIndex"]))
                ViewState[CURRINDEX] = this.Request.Params["currIndex"];
            else
                ViewState[CURRINDEX] = 0;

            if (!String.IsNullOrEmpty(this.Request["value"]))
            {

                WarmupBLL wbll1 = new WarmupBLL(2052);
                MediaNum mn = wbll1.returnMediaNum(this.Request["value"], 2052);
                ViewState["picNum"] = mn.Imgnum.ToString();
                ViewState["videoNum"] = mn.Videonum.ToString();
                ViewState["wordNum"] = searchCount;
                ViewState["value"] = this.Request["value"];
                wordCount = ViewState["wordNum"].ToString();
                picCount = ViewState["picNum"].ToString();
                videoCount = ViewState["videoNum"].ToString();
                SearchByParagraph(ViewState["value"].ToString(), 0);
            }
            if (!string.IsNullOrEmpty(this.Request.Params["keywords"]))
            {
                WarmupBLL wblla = new WarmupBLL(2052);
                MediaNum mna = wblla.returnMediaNum(this.Request.Params["keywords"].ToString(), 2052);
                ViewState["picNum"] = mna.Imgnum.ToString();
                ViewState["videoNum"] = mna.Videonum.ToString();
                ViewState["wordNum"] = searchCount;
                ViewState["value"] = this.Request.Params["keywords"];
                wordCount = ViewState["wordNum"].ToString();
                picCount = ViewState["picNum"].ToString();
                videoCount = ViewState["videoNum"].ToString();
            }
            if (!string.IsNullOrEmpty(this.Request.Params["type"]) && !string.IsNullOrEmpty(this.Request.Params["keywords"]))  //type 0 文字分页 1 图片分页 2 视频分页
            {
                string dataType = this.Request.Params["type"].ToString();
                switch (dataType)
                {
                    case "0": //文字分页
                        this.leixing.Value = "";
                        string key = Request.Params["keywords"].ToString(); //关键字
                        int pIndex = int.Parse(ViewState[CURRINDEX].ToString().Substring(0, 1)); //当前页号
                        SearchByParagraph(key, pIndex);
                        break;
                    case "1": //图片分页
                        this.leixing.Value = "pic"; // 前台样式为图片
                        string keywords = Request.Params["keywords"].ToString(); //关键字
                        int pageIndex = int.Parse(ViewState[CURRINDEX].ToString().Substring(0, 1)); //当前页号
                        imgEventsResult = GetEventsImgValue(keywords, pageIndex, IMAGE_PAGESIZE);
                        SearchByParagraph(keywords, 0);
                        wordCount = searchCount;
                        picCount = ViewState["picNum"].ToString();
                        videoCount = ViewState["videoNum"].ToString();
                        break;
                    case "2"://视频分页
                        this.leixing.Value = "video"; //  前台样式为视频
                        string keyword = Request.Params["keywords"].ToString(); //关键字
                        int pagingIndex = int.Parse(ViewState[CURRINDEX].ToString().Substring(0, 1)); //当前页号
                        SearchByParagraph(this.Request.Params["keywords"].ToString(), 0);
                        imgEventsResult = GetEventsImgValue(keyword, pagingIndex, VIDEO_PAGESIZE);
                        break;
                    default:
                        WarmupBLL wblla = new WarmupBLL(2052);
                        MediaNum mna = wblla.returnMediaNum(this.Request.Params["keywords"].ToString(), 2052);
                        SearchByParagraph(this.Request.Params["keywords"].ToString(), 0);
                        ViewState["picNum"] = mna.Imgnum.ToString();
                        ViewState["videoNum"] = mna.Videonum.ToString();
                        ViewState["wordNum"] = searchCount;
                        ViewState["value"] = this.Request.Params["keywords"].ToString();
                        wordCount = ViewState["wordNum"].ToString();
                        picCount = ViewState["picNum"].ToString();
                        videoCount = ViewState["videoNum"].ToString();
                        break;
                }
            }
        }
    }


   

    /// <summary>
    /// 搜索
    /// </summary>

    public void SearchByParagraph(string searchValue, int cupageIndex)
    {
        OgilvyOne.UKNow.BLL.SearchBll searchBll = new OgilvyOne.UKNow.BLL.SearchBll();
        searchBll.FilePath = GetFilePath();
        searchBll.IndexPath = GetIndexPath();
        searchBll.IsCreate = true;
        SearchTop.Text = searchValue;
        if (!string.IsNullOrEmpty(searchValue))
        {
            searchBll.SearchKey = searchValue.Trim();
        }

        if (string.IsNullOrEmpty(searchBll.SearchKey))
        {
            if (string.IsNullOrEmpty(searchBll.SearchResult))
            {
                if ((string)ViewState["result"] != null)
                {
                    searchResult = (string)ViewState["result"];

                }
                if ((string)ViewState["searchcount"] != null)
                {
                    wordCount = (string)ViewState["searchcount"];

                }
            }
            ScriptManager.RegisterClientScriptBlock(Page, GetType(), "", "alert('请输入搜索关键字')", true);
            return;
        }

        searchBll.QueryByParagraph();
        searchKey = searchBll.SearchKey;
        searchCount = searchBll.ResultCount;
        wordCount = searchBll.ResultCount;

        ViewState["searchcount"] = searchBll.ResultCount;
        // searchResult = searchBll.SearchResult;
        searchResult = searchBll.SearchValueByKeyinPage(searchValue, cupageIndex, VIDEO_PAGESIZE);
        // ViewState["result"] = searchBll.SearchResult;
        ViewState["result"] = searchResult;
        if (hideSearchType.Value == "left")
        {
            SearchLeft.Text = searchValue;
        }
        else
        {
            SearchTop.Text = searchValue;
        }
    }

    /// <summary>
    /// 获取文件路径
    /// </summary>
    /// <returns></returns>
    private string GetFilePath()
    {
        string path_file = ConfigurationSettings.AppSettings["CnPathFile"];
        return GetRootPath() + path_file;
    }

    /// <summary>
    /// 获取索引文件路径
    /// </summary>
    /// <returns></returns>
    private string GetIndexPath()
    {
        string indexPath = ConfigurationSettings.AppSettings["CnPathIndex"]; ;
        return GetRootPath() + indexPath;
    }


    /// <summary>
    /// 获取根目录
    /// </summary>
    /// <returns></returns>
    private string GetRootPath()
    {
        return Server.MapPath("~");
    }


    //上部搜索框 点击事件
    protected void lkbSearchTop_Click(object sender, EventArgs e)
    {
        //wordCount = ViewState["wordNum"].ToString();
        //picCount = ViewState["picNum"].ToString();
        //videoCount = ViewState["videoNum"].ToString();
        //#region
        //SearchLeft.Text = "";
        //SearchLeft.Text = SearchTop.Text;
        //this.leixing.Value = "";
        //ViewState["value"] = SearchTop.Text;
        //WarmupBLL wbll1 = new WarmupBLL(2052);
        //MediaNum mn = wbll1.returnMediaNum(SearchTop.Text, 2052);
        //ViewState["picNum"] = mn.Imgnum.ToString();
        //ViewState["videoNum"] = mn.Videonum.ToString();
        //ViewState["wordNum"] = searchCount;
        //wordCount = ViewState["wordNum"].ToString();
        //picCount = ViewState["picNum"].ToString();
        //videoCount = ViewState["videoNum"].ToString();
        //SearchByParagraph(SearchTop.Text, 0);
        //#endregion
        //imgSeaResult = ShowImg();
        this.leixing.Value = "";

        Response.Redirect("search.aspx?type=0&currIndex=0&keywords=" + SearchTop.Text + "");
    }
    //左侧搜索 点击事件
    protected void lkbSearch_Click(object sender, EventArgs e)
    {
        //wordCount = ViewState["wordNum"].ToString();
        //picCount = ViewState["picNum"].ToString();
        //videoCount = ViewState["videoNum"].ToString();
        this.leixing.Value = "";
        //SearchTop.Text = "";
        //SearchTop.Text = SearchLeft.Text;
        //ViewState["value"] = SearchLeft.Text;
        //WarmupBLL wbll1 = new WarmupBLL(2052);
        //MediaNum mn = wbll1.returnMediaNum(SearchLeft.Text, 2052);
        //ViewState["picNum"] = mn.Imgnum.ToString();
        //ViewState["videoNum"] = mn.Videonum.ToString();
        //ViewState["wordNum"] = searchCount;
        //wordCount = ViewState["wordNum"].ToString();
        //picCount = ViewState["picNum"].ToString();
        //videoCount = ViewState["videoNum"].ToString();
        Response.Redirect("search.aspx?type=0&currIndex=0&keywords=" + SearchLeft.Text + "");
        //SearchByParagraph(SearchLeft.Text, 0);
        //imgSeaResult = ShowImg();
    }
    //图片 点击事件
    protected void pic_Click(object sender, EventArgs e)
    {
        if (ViewState["value"] != null)
        {
            this.leixing.Value = "pic";
            //wordCount = ViewState["wordNum"].ToString();
            //picCount = ViewState["picNum"].ToString();
            //videoCount = ViewState["videoNum"].ToString();
            Response.Redirect("search.aspx?type=1&currIndex=0&keywords=" + ViewState["value"].ToString() + "");
            
            //imgEventsResult = GetEventsImgValue(ViewState["value"].ToString(), 0, IMAGE_PAGESIZE);
            //imgWarmUpResult = GetWarmUpImgValue(ViewState["value"].ToString(), 1, 25);
        }
    }
    //视频 点击事件
    protected void video_Click(object sender, EventArgs e)
    {
        if (ViewState["value"] != null)
        {
            this.leixing.Value = "video";
            //wordCount = ViewState["wordNum"].ToString();
            //picCount = ViewState["picNum"].ToString();
            //videoCount = ViewState["videoNum"].ToString();
            //wordCount = ViewState["wordNum"].ToString();
            //picCount = ViewState["picNum"].ToString();
            //videoCount = ViewState["videoNum"].ToString();
            Response.Redirect("search.aspx?type=2&currIndex=0&keywords=" + ViewState["value"].ToString() + "");
            //videoSeaResult = GetEventsVideoValue(ViewState["value"].ToString(), 0, VIDEO_PAGESIZE);
        }
    }
    //文字 点击事件
    protected void words_Click(object sender, EventArgs e)
    {
        if (ViewState["value"] != null)
        {
            this.leixing.Value = "word";
            wordCount = ViewState["wordNum"].ToString();
            picCount = ViewState["picNum"].ToString();
            videoCount = ViewState["videoNum"].ToString();
            //wordCount = ViewState["wordNum"].ToString();
            //picCount = ViewState["picNum"].ToString();
            //videoCount = ViewState["videoNum"].ToString();

            SearchTop.Text = ViewState["value"].ToString();
            SearchLeft.Text = ViewState["value"].ToString();
            Response.Redirect("search.aspx?type=0&currIndex=0&keywords=" + ViewState["value"].ToString() + "");
            //SearchByParagraph(ViewState["value"].ToString(), 0);
        }
    }
}
